﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace JeuDeDames_v1._02
{
    public partial class InterfaceJeu : Form
    {
        //Images des pions et dames
        private Bitmap pionNoir = Properties.Resources.plainBlack48;
        private Bitmap dameNoire = Properties.Resources.plainBlackKing48;
        private Bitmap pionBlanc = Properties.Resources.plainWhite48;
        private Bitmap dameBlanche = Properties.Resources.plainWhiteKing48;

        //Couleur
        Color Noir   = Color.FromArgb(48, 48, 48);
        Color Blanc  = Color.FromArgb(248, 248, 248);
        Color Select = Color.FromArgb(0, 123, 198);

        // c'est au joueur blanc de jouer
        bool tourJB = true;

        public InterfaceJeu()
        {
            InitializeComponent();
            loadGame();
        }

        public void loadGame()
        {
            bool alternate = true;
            for (int y = 0; y < 10; y++)
            {
                if (alternate) alternate = false;
                else alternate = true;
                for (int x = 0; x < 10; x++)
                {
                    TLPdamier.ColumnStyles[x].SizeType = SizeType.Percent;
                    TLPdamier.ColumnStyles[x].Width = 10;
                    TLPdamier.RowStyles[y].SizeType = SizeType.Percent;
                    TLPdamier.ColumnStyles[y].Width = 10;
                    Panel template = new Panel();
                    template.Margin = new System.Windows.Forms.Padding(1);
                    template.Padding = Padding.Empty;
                    template.BackgroundImageLayout = ImageLayout.Center;
                    template.Name = "cell" + x + "" + y;
                    if (alternate)
                    {
                        if (x % 2 == 1)
                        {
                            template.BackColor = Noir;
                        }
                        else
                        {
                            template.BackColor = Blanc;
                        }
                    }
                    else
                    {
                        if (x % 2 == 1)
                        {
                            template.BackColor = Blanc;
                        }
                        else
                        {
                            template.BackColor = Noir;
                        }
                    }
                    template.Dock = DockStyle.Fill;
                    template.Click += new EventHandler(clicCase);
                    TLPdamier.Controls.Add(template, x, y);
                }
            }
        } //loadGame()

        public int index(int ligne, int colonne)
        {
            return colonne + (10 * ligne);
        } // index()

        void clicCase(object sender, EventArgs e)
        {
            TableLayoutPanelCellPosition temp = TLPdamier.GetCellPosition((Control)sender);

           // if (
            //if (TurnSwitch == Data.TurnState.black)
            //{
            //    ResetTileColor(currentCell.Index());
            //    if (ClickBlack_Move(Data.C(tmp.Row, tmp.Column)))
            //    {
            //        txtStatus.Text = "White's Turn";
            //        TurnSwitch = Data.TurnState.white;
            //    }
            //}
            //if (TurnSwitch == Data.TurnState.white)
            //{
            //    ResetTileColor(currentCell.Index());
            //    if (ClickWhite_Move(Data.C(tmp.Row, tmp.Column)))
            //    {
            //        txtStatus.Text = "Black's Turn";
            //        TurnSwitch = Data.TurnState.black;
            //    }
            //}
        } // clicCase()

    }
}
